<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <style>
    body {
      width: 320px;
      padding: 0;
      background: #1a1a1a;
      color: #fff;
      font-family: 'Arial', sans-serif;
      margin: 0;
      overflow: hidden;
    }

    .container {
      background: linear-gradient(145deg, #232323, #1a1a1a);
      border-radius: 0;
      padding: 20px;
      box-shadow: 0 8px 16px rgba(0,0,0,0.3);
      max-height: 600px;
      overflow-y: auto;
    }

    /* 自定义滚动条样式 */
    .container::-webkit-scrollbar {
      width: 6px;
    }

    .container::-webkit-scrollbar-track {
      background: transparent;
    }

    .container::-webkit-scrollbar-thumb {
      background: #444;
      border-radius: 3px;
    }

    .container::-webkit-scrollbar-thumb:hover {
      background: #555;
    }

    h3 {
      margin: 0 0 15px 0;
      padding-bottom: 10px;
      border-bottom: 1px solid #333;
      color: #c34;
      font-size: 20px;
      text-transform: uppercase;
      letter-spacing: 1px;
      text-align: center;
      text-shadow: 0 0 10px rgba(204,51,68,0.3);
    }

    .status {
      background: #2a2a2a;
      padding: 12px;
      border-radius: 8px;
      margin-bottom: 20px;
      border: 1px solid #333;
      display: flex;
      flex-direction: column;
      gap: 8px;
      position: relative;
      overflow: hidden;
    }

    .status-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .status::before {
      content: '';
      position: absolute;
      width: 8px;
      height: 8px;
      background: var(--status-color, #666);
      border-radius: 50%;
      left: 15px;
      animation: pulse 2s infinite;
    }

    @keyframes pulse {
      0% { transform: scale(1); opacity: 1; }
      50% { transform: scale(1.5); opacity: 0.5; }
      100% { transform: scale(1); opacity: 1; }
    }
    .history-last-update {
          font-size: 12px;
          color: #f5f1f1;
          margin-bottom: 10px;
        }
    .status-text {
      margin-left: 25px;
      font-size: 14px;
      color: #ddd;
    }

    .config {
      padding: 15px;
      border-radius: 8px;
      border: 1px solid #333;
    }

    .input-group {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 15px;
    }

    input[type="number"] {
      background: #333;
      border: none;
      border-radius: 4px;
      padding: 8px;
      width: 60px;
      color: #fff;
      font-size: 14px;
      text-align: center;
      transition: all 0.3s ease;
    }

    input[type="number"]:focus {
      outline: none;
      box-shadow: 0 0 0 2px #c34;
      background: #404040;
    }

    .save-btn {
      width: 100%;
      padding: 10px;
      border: none;
      border-radius: 6px;
      background: linear-gradient(45deg, #c34, #e45);
      color: white;
      font-weight: bold;
      cursor: pointer;
      transition: all 0.3s ease;
      text-transform: uppercase;
      letter-spacing: 1px;
      font-size: 14px;
    }

    .save-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(204,51,68,0.3);
    }

    .save-btn:active {
      transform: translateY(0);
    }

    /* 添加提示气泡样式 */
    .tooltip {
      position: absolute;
      background: #c34;
      padding: 8px 12px;
      border-radius: 4px;
      font-size: 12px;
      color: white;
      display: none;
      animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(10px); }
      to { opacity: 1; transform: translateY(0); }
    }

    /* 添加历史记录样式 */
    .history-section {
      margin-top: 20px;
      background: #2a2a2a;
      padding: 15px;
      border-radius: 8px;
      border: 1px solid #333;
    }

    .history-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
    }

    .history-title {
      color: #c34;
      font-size: 16px;
      font-weight: bold;
    }

    .history-limit {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .history-list {
      max-height: 250px;
      overflow-y: auto;
      margin-right: -8px;
      padding-right: 8px;
    }

    /* 历史记录列表的滚动样式 */
    .history-list::-webkit-scrollbar {
      width: 4px;
    }

    .history-list::-webkit-scrollbar-track {
      background: transparent;
    }

    .history-list::-webkit-scrollbar-thumb {
      background: #444;
      border-radius: 2px;
    }

    .history-list::-webkit-scrollbar-thumb:hover {
      background: #555;
    }

    .bug-item {
      padding: 10px;
      border-radius: 4px;
      background: #333;
      margin-bottom: 6px;
      cursor: pointer;
      transition: all 0.3s ease;
      border: 1px solid transparent;
    }

    .bug-item:hover {
      background: #404040;
      border-color: #c34;
      transform: translateX(2px);
    }

    .bug-item:last-child {
      margin-bottom: 0;
    }

    .bug-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 8px;
      margin-bottom: 5px;
    }

    .bug-state {
      font-size: 12px;
      padding: 2px 6px;
      border-radius: 3px;
      background: #444;
      color: #fff;
      white-space: nowrap;
    }

    .bug-state.open {
      background: #c34;
    }

    .bug-state.progressing {
      background: #4a9;
    }

    .bug-state.closed {
      background: #47b;
    }

    .bug-state.rejected {
      background: #666;
    }

    .bug-title {
      flex: 1;
      color: #fff;
      font-size: 14px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .bug-meta {
      color: #888;
      font-size: 12px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .bug-time {
      color: #666;
    }

    .bug-number {
      color: #888;
      font-family: monospace;
    }

    .no-bugs {
      color: #666;
      text-align: center;
      padding: 20px;
    }

    .history-config {
      margin-bottom: 15px;
      padding: 8px;
      background: #333;
      border-radius: 4px;
    }

    .open-mode {
      display: flex;
      align-items: center;
      gap: 8px;
      color: #ddd;
      font-size: 14px;
      cursor: pointer;
      margin: 0;
    }

    .open-mode input[type="checkbox"] {
      width: 16px;
      height: 16px;
      cursor: pointer;
    }

    .refresh-btn {
      position: absolute;
      right: 10px;
      background: #333;
      border: 1px solid #444;
      color: #fff;
      padding: 5px 10px;
      border-radius: 4px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 5px;
      transition: all 0.3s ease;
    }

    .refresh-btn:hover {
      background: #404040;
      transform: translateY(-1px);
    }

    .refresh-btn:active {
      transform: translateY(0);
    }

    .refresh-btn.loading .refresh-icon {
      animation: spin 1s linear infinite;
    }

    @keyframes spin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }

    .refresh-icon {
      display: inline-block;
      font-size: 16px;
    }

    .token-help {
      margin-top: 10px;
      text-align: center;
      font-size: 12px;
      margin-bottom: 10px;
    }

    .token-help a {
      color: #c34;
      text-decoration: none;
    }

    .token-help a:hover {
      text-decoration: underline;
    }

    input[type="password"] {
      background: #333;
      border: none;
      border-radius: 4px;
      padding: 8px;
      color: #fff;
      font-size: 14px;
      width: 100%;
      transition: all 0.3s ease;
    }

    input[type="password"]:focus {
      outline: none;
      box-shadow: 0 0 0 2px #c34;
      background: #404040;
    }

    select {
      background: #333;
      border: none;
      border-radius: 4px;
      padding: 8px;
      color: #fff;
      font-size: 14px;
      width: 100%;
      transition: all 0.3s ease;
      cursor: pointer;
    }

    select:focus {
      outline: none;
      box-shadow: 0 0 0 2px #c34;
      background: #404040;
    }

    select:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    /* 设置抽屉样式 */
    .settings-drawer {
      position: fixed;
      right: -320px;
      top: 0;
      width: 320px;
      height: 100%;
      background: #2a2a2a;
      transition: right 0.3s ease;
      z-index: 1000;
      box-shadow: -2px 0 8px rgba(0,0,0,0.3);
    }

    .settings-drawer.open {
      right: 0;
    }

    .settings-toggle {
      position: absolute;
      left: -40px;
      top: 50%;
      transform: translateY(-50%);
      width: 40px;
      height: 40px;
      background: linear-gradient(145deg, #333, #2a2a2a);
      border: none;
      border-radius: 6px 0 0 6px;
      color: #fff;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: -2px 0 8px rgba(0,0,0,0.3),
                  inset 1px 1px 1px rgba(255,255,255,0.1);
      transition: all 0.3s ease;
    }

    .settings-toggle:hover {
      background: linear-gradient(145deg, #3a3a3a, #333);
      transform: translateY(-50%) translateX(-2px);
      box-shadow: -3px 0 12px rgba(0,0,0,0.4),
                  inset 1px 1px 1px rgba(255,255,255,0.15);
    }

    .settings-toggle:active {
      background: linear-gradient(145deg, #2a2a2a, #252525);
      transform: translateY(-50%) translateX(0);
      box-shadow: -2px 0 8px rgba(0,0,0,0.3),
                  inset 1px 1px 1px rgba(255,255,255,0.05);
    }

    .settings-icon {
      fill: #c34;
      opacity: 0.9;
      transition: all 0.3s ease;
      transform-origin: center;
      display: inline-block;
      width: 22px;
      height: 22px;
      filter: drop-shadow(0 0 2px rgba(204,51,68,0.3));
    }

    .settings-toggle:hover .settings-icon {
      opacity: 1;
      filter: drop-shadow(0 0 4px rgba(204,51,68,0.5));
      animation: settingsRotate 1s linear infinite;
    }

    @keyframes settingsRotate {
      from {
        transform: rotate(0deg);
      }
      to {
        transform: rotate(360deg);
      }
    }

    .settings-content {
      padding: 20px;
      height: 100%;
      overflow-y: auto;
    }

    .settings-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
    }

    .close-btn {
      background: none;
      border: none;
      color: #fff;
      font-size: 20px;
      cursor: pointer;
      padding: 8px;
      border-radius: 4px;
      transition: all 0.3s ease;
    }

    .close-btn:hover {
      background: #333;
      transform: scale(1.1);
    }

    .close-btn:active {
      transform: scale(0.9);
    }

    .status-info {
      color: #888;
      font-size: 12px;
      margin-left: 25px;
    }

    .status.not-configured::before {
      --status-color: #c34;
    }

    .status.monitoring::before {
      --status-color: #4CAF50;
    }

    .status.error::before {
      --status-color: #ff4444;
      animation: none;
    }

    .status.error .status-text {
      color: #ff4444;
    }

    .history-title-group {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .last-update {
      font-size: 12px;
      color: #666;
      font-weight: normal;
    }
  </style>
</head>
<body>
  <div class="container">
    <h3>Gitee 通知助手</h3>
    <div class="status" id="statusPanel">
      <div class="status-row">
        <span class="status-text">未配置</span>
        <button id="refreshBtn" class="refresh-btn">
          <span class="refresh-icon">↻</span>
          立即检测
        </button>
      </div>
      <div class="status-info" id="lastCheckTime"></div>
    </div>

    <!-- 设置抽屉 -->
    <div class="settings-drawer" id="settingsDrawer">
      <button class="settings-toggle" id="settingsToggle">
        <svg class="settings-icon" viewBox="0 0 24 24" width="20" height="20">
          <path d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 
            l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 
            h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 
            C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 
            c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 
            c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 
            c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 
            s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z"/>
        </svg>
      </button>
      <div class="settings-content">
        <div class="settings-header">
          <p class="settings-title" style="margin: 0; padding: 15px; font-size: 18px; color: #fff; border-bottom: 1px solid #333; text-align: center; font-weight: bold;">设置</p>
          <button class="close-btn" id="closeSettings">✕</button>
        </div>
        <div class="config">
          <div class="input-group">
            <label>Access Token:</label>
            <input type="password" id="accessToken" placeholder="请输入 Gitee Access Token" style="width: 200px">
          </div>
          <div class="input-group">
            <label>企业空间:</label>
            <select id="enterprise" style="flex: 1"></select>
          </div>
          <div class="input-group">
            <label>检查频率：每</label>
            <input type="number" id="interval" min="1" max="60" value="5">
            <label>分钟</label>
          </div>
          <div class="input-group">
            <label>显示数量：</label>
            <input type="number" id="historyLimit" min="1" max="10" value="10" style="width: 60px">
            <label>条</label>
          </div>
          <div class="input-group">
            <label class="open-mode">
              <input type="checkbox" id="openInNewTab">
              在新标签页打开
            </label>
          </div>
          <button class="save-btn" id="saveConfig">保存设置</button>
          <div class="token-help">
            <a href="https://gitee.com/profile/personal_access_tokens" target="_blank">
              如何获取 Access Token?
            </a>
          </div>
        </div>
      </div>
    </div>

    <!-- 添加历史记录部分 -->
    <div class="history-section">
      <div class="history-header">
        <span class="history-title">最近的 Bug</span>
      </div>
      <div class="history-list" id="bugList">
        <!-- Bug列表将通过 JS 动态插入 -->
      </div>
    </div>
  </div>
  <script src="popup.js"></script>
</body>
</html> 